package n1979;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	
	static char[][] arr=new char[21][21];
	
	static int count;
	
	static int M,N;
	
	static boolean v[][]=new boolean[21][21];
	
	
	static void init()
	{
		count=0;
		for(int i=0;i<M;i++)
			for(int j=0;j<N;j++)
				v[i][j]=false;
	}
	
	
	static void solve(int i,int j)
	{
		if(i<0||i>=M||j<0||j>=N||v[i][j]==true||arr[i][j]=='#')return;
		count++;
		v[i][j]=true;
		solve(i-1,j);
		solve(i,j+1);
		solve(i+1,j);
		solve(i,j-1);
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{

		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		String line=null;
		while((line=bf.readLine())!=null)
		{
			StringTokenizer st=new StringTokenizer(line);
			N=Integer.parseInt(st.nextToken());
			M=Integer.parseInt(st.nextToken());
			if(M==0&&N==0)break;
			int si=0,sj=0;
			for(int i=0;i<M;i++)
			{
				String tmp=bf.readLine();
				for(int j=0;j<N;j++)
				{
					arr[i][j]=tmp.charAt(j);
					if(arr[i][j]=='@'){
						si=i;
						sj=j;
					}
				}
			}
			init();
			solve(si,sj);
			System.out.println(count);
		}
	}

}
